# -*- coding: UTF-8 -*-
# @Project ：luffycity 
# @File    ：翻页.py
# @Author  ：于金龙
# @IDE     ：PyCharm 
# @Date    ：2024/4/7 17:25
# TODO:将数据分装到对象中在方法对原始数据进行加工数据
# # 数据准备
user_list = ["用户{}".format(i) for i in range(1, 3000)]
# # 之前的思路（非面向对象方式编程）
# while True:
#     page = int(input("输入页数"))
#     start_page = (page - 1) * 10
#     end_page = page * 10
#     page_list = user_list[start_page:end_page]
#     for item in page_list:
#         print(item)


class Pagination:
    def __init__(self, current_page, page_len=10):
        self.page_len = page_len
        if not current_page.isdecimal():
            self.current_page = 1
            return
        current_page = int(current_page)
        if current_page < 1:
            self.current_page = 1
            return
        self.current_page = current_page

    def start(self):
        return (self.current_page - 1) * self.page_len

    def end(self):
        return self.current_page * 10


if __name__ == '__main__':
    while True:
        page = input("输入页码")

        pg_object = Pagination(page,10)
        page_data_list = user_list[pg_object.start():pg_object.end()]
        for item in page_data_list:
            print(item)
